﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My.Resources;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_DatabaseChiNhanh : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboDataBase")]
        private ComboBox _CboDataBase;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("CmdTestConnect")]
        private Button _CmdTestConnect;
        [AccessedThroughProperty("GroupBox1")]
        private GroupBox _GroupBox1;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label3")]
        private Label _Label3;
        [AccessedThroughProperty("Label4")]
        private Label _Label4;
        [AccessedThroughProperty("TxtPassword")]
        private TextBox _TxtPassword;
        [AccessedThroughProperty("TxtServer")]
        private TextBox _TxtServer;
        [AccessedThroughProperty("TxtUserName")]
        private TextBox _TxtUserName;
        private IContainer components;
        private clsDuLieuChiNhanh objDLCN;
        public string strKhoaDoiTuong;

        public Frm_DatabaseChiNhanh()
        {
            base.Load += new EventHandler(this.Frm_MayChuChiNhanh_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.objDLCN = new clsDuLieuChiNhanh();
            this.strKhoaDoiTuong = "";
            this.InitializeComponent();
        }

        public void BuildComboDatabase()
        {
            string commandText = "";
            try
            {
                this.CboDataBase.Items.Clear();
                commandText = "SELECT Name FROM master.dbo.sysdatabases WHERE dbid > 6 ORDER BY Name";
                DataTable table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                int num2 = table.Rows.Count - 1;
                for (int i = 0; i <= num2; i++)
                {
                    this.CboDataBase.Items.Add(RuntimeHelpers.GetObjectValue(table.Rows[i]["Name"]));
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                LVYModule.ShowWarning(exception.Message);
                ProjectData.ClearProjectError();
            }
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            clsDuLieuChiNhanh objDLCN = this.objDLCN;
            objDLCN.TenMayChu = this.TxtServer.Text.Trim();
            objDLCN.TenDataBase = this.CboDataBase.Text.Trim();
            objDLCN.NguoiDung = this.TxtUserName.Text;
            objDLCN.MatKhau = this.TxtPassword.Text;
            objDLCN.Loai = 0;
            objDLCN.Save();
            objDLCN = null;
            this.Dispose();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_MayChuChiNhanh_Load(object sender, EventArgs e)
        {
            if (LVYModule.ReturnIfNull(this.strKhoaDoiTuong, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                this.Dispose();
            }
            else
            {
                this.BuildComboDatabase();
                this.ShowData();
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.CmdOK = new Button();
            this.GroupBox1 = new GroupBox();
            this.CboDataBase = new ComboBox();
            this.Label3 = new Label();
            this.TxtPassword = new TextBox();
            this.Label2 = new Label();
            this.TxtUserName = new TextBox();
            this.Label1 = new Label();
            this.TxtServer = new TextBox();
            this.Label4 = new Label();
            this.CmdTestConnect = new Button();
            this.CmdCancel = new Button();
            this.GroupBox1.SuspendLayout();
            this.SuspendLayout();
            Point point = new Point(0xaf, 170);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            Size size = new Size(0x4f, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 14;
            this.CmdOK.Text = "&OK";
            this.CmdOK.UseVisualStyleBackColor = true;
            this.GroupBox1.BackColor = Color.Transparent;
            this.GroupBox1.Controls.Add(this.CboDataBase);
            this.GroupBox1.Controls.Add(this.Label3);
            this.GroupBox1.Controls.Add(this.TxtPassword);
            this.GroupBox1.Controls.Add(this.Label2);
            this.GroupBox1.Controls.Add(this.TxtUserName);
            this.GroupBox1.Controls.Add(this.Label1);
            this.GroupBox1.Controls.Add(this.TxtServer);
            this.GroupBox1.Controls.Add(this.Label4);
            point = new Point(7, 6);
            this.GroupBox1.Location = point;
            this.GroupBox1.Name = "GroupBox1";
            size = new Size(0x158, 0x9b);
            this.GroupBox1.Size = size;
            this.GroupBox1.TabIndex = 13;
            this.GroupBox1.TabStop = false;
            this.GroupBox1.Text = "Th\x00f4ng tin kết nối cơ sở dữ liệu SQL";
            this.CboDataBase.FormattingEnabled = true;
            point = new Point(0x51, 0x35);
            this.CboDataBase.Location = point;
            this.CboDataBase.Name = "CboDataBase";
            size = new Size(0xe9, 0x15);
            this.CboDataBase.Size = size;
            this.CboDataBase.TabIndex = 0x2c;
            this.Label3.AutoSize = true;
            point = new Point(9, 0x6d);
            this.Label3.Location = point;
            this.Label3.Name = "Label3";
            size = new Size(0x35, 13);
            this.Label3.Size = size;
            this.Label3.TabIndex = 0x2b;
            this.Label3.Text = "Password";
            point = new Point(0x51, 0x6a);
            this.TxtPassword.Location = point;
            this.TxtPassword.Name = "TxtPassword";
            this.TxtPassword.PasswordChar = '*';
            size = new Size(0xe9, 20);
            this.TxtPassword.Size = size;
            this.TxtPassword.TabIndex = 0x2a;
            this.Label2.AutoSize = true;
            point = new Point(9, 0x53);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x3a, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 0x29;
            this.Label2.Text = "User name";
            point = new Point(0x51, 80);
            this.TxtUserName.Location = point;
            this.TxtUserName.Name = "TxtUserName";
            size = new Size(0xe9, 20);
            this.TxtUserName.Size = size;
            this.TxtUserName.TabIndex = 40;
            this.Label1.AutoSize = true;
            point = new Point(9, 0x39);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x35, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 0x27;
            this.Label1.Text = "Database";
            point = new Point(0x51, 0x1b);
            this.TxtServer.Location = point;
            this.TxtServer.Name = "TxtServer";
            this.TxtServer.ReadOnly = true;
            size = new Size(0xe9, 20);
            this.TxtServer.Size = size;
            this.TxtServer.TabIndex = 0x26;
            this.Label4.AutoSize = true;
            point = new Point(9, 0x1f);
            this.Label4.Location = point;
            this.Label4.Name = "Label4";
            size = new Size(0x43, 13);
            this.Label4.Size = size;
            this.Label4.TabIndex = 0x25;
            this.Label4.Text = "Server name";
            point = new Point(0x11, 170);
            this.CmdTestConnect.Location = point;
            this.CmdTestConnect.Name = "CmdTestConnect";
            size = new Size(0x51, 0x18);
            this.CmdTestConnect.Size = size;
            this.CmdTestConnect.TabIndex = 0x10;
            this.CmdTestConnect.Text = "&Test connect";
            this.CmdTestConnect.UseVisualStyleBackColor = true;
            point = new Point(0x108, 170);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x4f, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 15;
            this.CmdCancel.Text = "&Cancel";
            this.CmdCancel.UseVisualStyleBackColor = true;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.background;
            size = new Size(0x165, 0xc6);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.CmdOK);
            this.Controls.Add(this.GroupBox1);
            this.Controls.Add(this.CmdTestConnect);
            this.Controls.Add(this.CmdCancel);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Frm_DatabaseChiNhanh";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "DATA CHI NHANH TAI TRUNG TAM";
            this.GroupBox1.ResumeLayout(false);
            this.GroupBox1.PerformLayout();
            this.ResumeLayout(false);
        }

        public void ShowData()
        {
            string str3 = "";
            string str4 = "";
            string str2 = "";
            modGeneral.H_KEYAPPNAME = modGeneral.MD5Encrypt("ERP");
            str3 = Interaction.GetSetting(modGeneral.H_KEYAPPNAME, "CONNECT", "SERVERNAME", "");
            str4 = Interaction.GetSetting(modGeneral.H_KEYAPPNAME, "CONNECT", "USERNAME", "");
            str2 = Interaction.GetSetting(modGeneral.H_KEYAPPNAME, "CONNECT", "PASSWORD", "");
            clsDuLieuChiNhanh objDLCN = this.objDLCN;
            if (objDLCN.Load(this.strKhoaDoiTuong, 0))
            {
                this.TxtServer.Text = str3;
                this.CboDataBase.Text = objDLCN.TenDataBase;
                this.TxtUserName.Text = objDLCN.NguoiDung;
                this.TxtPassword.Text = objDLCN.MatKhau;
            }
            else
            {
                this.TxtServer.Text = str3;
                this.CboDataBase.Text = "";
                this.TxtUserName.Text = str4;
                this.TxtPassword.Text = str2;
            }
            objDLCN = null;
        }

        internal virtual ComboBox CboDataBase
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboDataBase;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboDataBase = value;
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual Button CmdTestConnect
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdTestConnect;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CmdTestConnect = value;
            }
        }

        internal virtual GroupBox GroupBox1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._GroupBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._GroupBox1 = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label3 = value;
            }
        }

        internal virtual Label Label4
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label4;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label4 = value;
            }
        }

        internal virtual TextBox TxtPassword
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtPassword;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtPassword = value;
            }
        }

        internal virtual TextBox TxtServer
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtServer;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtServer = value;
            }
        }

        internal virtual TextBox TxtUserName
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtUserName;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtUserName = value;
            }
        }
    }
}

